package com.lxw.manage_cms.controller;

import com.lxw.api.cms.CmsConfigControllerApi;
import com.lxw.framework.domain.cms.CmsConfig;
import com.lxw.framework.domain.cms.response.CmsCode;
import com.lxw.framework.exception.ExceptionCast;
import com.lxw.framework.model.response.CommonCode;
import com.lxw.manage_cms.service.ICmsConfigService;
import com.lxw.manage_cms.service.ICmsTemplateService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("config")
public class CmsConfigController implements CmsConfigControllerApi {

    @Autowired
    ICmsConfigService iCmsConfigService;

    @Override
    @GetMapping("/get/{id}")
    public CmsConfig findById(@PathVariable String id) {

        if (StringUtils.isEmpty(id)){
            ExceptionCast.cast(CmsCode.CMS_COURSE_PAGEIDNOTEXISTS);
        }


        CmsConfig cmsConfig = iCmsConfigService.findById(id);

        return cmsConfig;
    }
}
